#pragma once

#ifndef _LITTLE_ENDIAN
#define IPQUAD(addr) \
	((unsigned char*)&addr)[0], \
	((unsigned char*)&addr)[1], \
	((unsigned char*)&addr)[2], \
	((unsigned char*)&addr)[3]
#else
#define IPQUAD(addr) \
	((unsigned char*)&addr)[3], \
	((unsigned char*)&addr)[2], \
	((unsigned char*)&addr)[1], \
	((unsigned char*)&addr)[0]
#endif // #ifndef _LITTLE_ENDIAN

u_int16_t checksum(u_int32_t init, u_int8_t *addr, size_t count);

u_int16_t ip_checksum(struct iphdr* iphdrp);

void set_ip_checksum(struct iphdr* iphdrp);

u_int16_t tcp_checksum2(struct iphdr* iphdrp, struct tcphdr* tcphdrp);

u_int16_t tcp_checksum1(struct iphdr* iphdrp);

void set_tcp_checksum2(struct iphdr* iphdrp, struct tcphdr* tcphdrp);

void set_tcp_checksum1(struct iphdr* iphdrp);


